#include <iostream>
#include <memory>
#include <signal.h>
#include "TcpServer.hpp"
#include "Calculator.hpp"
#include "Log.hpp"
Calculator calculator;
void DefaultOnMessage(std::shared_ptr<Connection> connection_ptr)
{
    std::cout << "上层得到了数据: " << connection_ptr->Inbuffer() << std::endl;
    std::string response_str = calculator.Handler(connection_ptr->Inbuffer());
    if (response_str.empty())
        return;
    lg(Debug, "%s", response_str.c_str());
    connection_ptr->AppendOutBuffer(response_str);
    connection_ptr->_send_cb(connection_ptr);
}
int main()
{
    std::unique_ptr<TcpServer> epsvr(new TcpServer(8888, DefaultOnMessage));

    epsvr->Init();
    signal(SIGPIPE, SIG_IGN);
    epsvr->Loop();
    return 0;
}